//官网demo案例
// https://www.tslang.cn/docs/handbook/classes.html
// 案例1
/* class Greeter {
    greeting: string;
    constructor(message:string) {
        this.greeting = message
    }
    greet(){
        return "hello, " + this.greeting
    }
}
let greeter = new Greeter('world') */

// 案例2
// 继承
/* class Animal {
    move(distaceInMeters: number = 0){
        console.log(`Animal moved ${distaceInMeters}m.`);
    }
}

class Dog extends Animal {
    bark(){
        console.log('woof! woof!');
    }
}

const dog = new Dog();
dog.bark()
dog.move(10)
dog.bark() */

// 案例3
/* class Animal {
    name:string;
    constructor(theName: string) {
        this.name = theName
    }
    move(distanceInMeters: number = 0) {
        console.log(`${this.name} moved ${distanceInMeters}m.`);
    }
}

class Snake extends Animal {
    constructor(name: string) {
        super(name)
    }
    move(distanceInMeters = 5){
        console.log("slithering....");
        super.move(distanceInMeters);
    }
}

class Horse extends Animal {
    constructor(name:string) {
        super(name)
    }
    move(distanceInMeters = 45){
        console.log('Galloping...');
        super.move(distanceInMeters);
    }
}

let sam = new Snake("Sammy ")
let tom:Animal = new Horse("Tommy ")

sam.move()
tom.move(34) */